﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TeamNectarine.WpfClient.ViewModels
{
    public class PhotoListViewModel : ObservableCollection<ImageFileViewModel>
    {
        public PhotoListViewModel() { }

        public PhotoListViewModel(string path) : this(new DirectoryInfo(path)) { }

        public PhotoListViewModel(DirectoryInfo directory)
        {
            _directory = directory;
            Update();
        }

        public string Path
        {
            set
            {
                _directory = new DirectoryInfo(value);
                Update();
            }
            get { return _directory.FullName; }
        }

        public DirectoryInfo Directory
        {
            set
            {
                _directory = value;
                Update();
            }
            get { return _directory; }
        }
        private void Update()
        {
            foreach (FileInfo f in _directory.GetFiles("*.jpg"))
            {
                Add(new ImageFileViewModel(f.FullName));
            }
        }

        DirectoryInfo _directory;
    }
}
